Skip to content

#702 Enhance branch layout for SHMetro 2020 style#775

Open
Unnamed2964 wants to merge 4 commits intorailmapgen:mainfrom
Unnamed2964:fix/shmetro-2020-branch-drawing
Open

#702 Enhance branch layout for SHMetro 2020 style#775
Unnamed2964 wants to merge 4 commits intorailmapgen:mainfrom
Unnamed2964:fix/shmetro-2020-branch-drawing

Conversation

@Unnamed2964
Copy link

@Unnamed2964 Unnamed2964 commented Feb 22, 2026

Partly resolve #702.

本 PR 对上海地铁 2020 样式(sh2020)的分支线绘制逻辑进行了优化,新增两个可调参数:

  1. 分支水平间距倍数(k_1):控制分岔点到离分岔点最近的分支首站的水平距离,范围 1-3,默认值 1
  2. 分支水平转弯偏移量(k_2):控制垂直转弯位置相对于分岔点的水平偏移,范围 0-3,默认值 0

此外还将方向箭头改为空心样式,在共线模式下使用黑色描边。

其他说明

本功能代码主要由 Claude Opus 4.5 辅助生成。
代码有经过人工审查。

如下图所示(本人拍摄),虽然 2020 版线路图处理分岔的一种情况是 #702 中所示的,但也的确存在从分岔点开始立刻分岔的画法,所以应该给予用户可调节参数。
IMG_20250525_200631

@Unnamed2964
Copy link
Author

疏忽大意了...我发现支线朝右的情况有问题,需要修复一下

@Unnamed2964
Copy link
Author

现在修好了

龙溪路

@Unnamed2964
Copy link
Author

由于修改了数据格式(添加了两个字段),所以可能需要算作一个新的版本号

@thekingofcity
Copy link
Member

抱歉我还需要一些时间才能来审阅这一和并请求 :(

@Unnamed2964
Copy link
Author

Unnamed2964 commented Feb 25, 2026

理解的

@Unnamed2964 Unnamed2964 force-pushed the fix/shmetro-2020-branch-drawing branch from de239f9 to bb2f1b6 Compare March 5, 2026 17:06
@Unnamed2964
Copy link
Author

Unnamed2964 commented Mar 5, 2026

新增了对 #732 的实现
无标题2
目前现实中有支线的所有线路(5、10、11号线)都显示出这种模式(论据见 #732 评论区),因此不提供选项。

- getStnState: promote parallel branch stations to state=1 when their
  forward junction is ahead of current station
- drawLine: guard against empty linePassStns array
- _linePath: gate main-path terminal caps on stnStates===1 to prevent
  coloring caps at current station
- _linePath: unify bifurcate section (remove redundant direction branches)
- coline-shmetro: fix _linePath call signature after stnStates param insert
- Add unit tests for getStnState and drawLine
@Unnamed2964 Unnamed2964 force-pushed the fix/shmetro-2020-branch-drawing branch from 5136faa to d59dd4f Compare March 5, 2026 17:24
@Unnamed2964
Copy link
Author

Unnamed2964 commented Mar 5, 2026

混进去了一些和本pr无关的提交,rebase分开了

@Unnamed2964 Unnamed2964 changed the title #702 Add branch layout fine-tuning controls for SHMetro 2020 style #702 Enhance branch layout for SHMetro 2020 style Mar 5, 2026
@Unnamed2964 Unnamed2964 force-pushed the fix/shmetro-2020-branch-drawing branch from 2e50cbb to 7673099 Compare March 6, 2026 06:01
@Unnamed2964
Copy link
Author

Unnamed2964 commented Mar 6, 2026

匹配上海地铁11号线站台屏蔽门上方线路图(下图为本人拍摄),添加了45度支线,以及站点较少分支的第一个站点是否和站点较多分支的第一个站点对齐作为选项
Image
rmg lxe3 Zhaofeng Road (1)

@Unnamed2964
Copy link
Author

rmg lxe3 Zhaofeng Road (3) rmg lxe3 Zhaofeng Road (4) rmg lxe3 Zhaofeng Road (2)

Comment on lines +286 to +310
/**
* SHMetro 2020 style branch layout control.
*/
shmetro2020_info: {
/**
* Factor for the horizontal distance from bifurcation point to first branch station.
* Default is 1, meaning normal spacing.
*/
branch_distance_factor: number;
/**
* Horizontal offset from bifurcation point where the vertical turn begins.
* Default is 0, meaning turn starts at bifurcation point.
*/
branch_first_station_offset: number;
/**
* Type of bend at bifurcation: 'rightangle' (90°) or '45degree' (45°).
* Default is 'rightangle'.
*/
branch_bend_type: 'rightangle' | '45degree';
/**
* Whether to align shorter branch endpoints to match the longer parallel branch.
* Default is false.
*/
branch_align_endpoints: boolean;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

通常来说我们希望所有的属性都是通用的,虽然可能现在非2020及其他风格不会用到对应的数据,但正像我们在loop中实现的那样(比如bank),尽可能地通用这些属性值和名,以便后续使用

另外它也应该和branchSpacingPct一起被整合在branch键下

Copy link
Member

@thekingofcity thekingofcity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

让我们先从这一个意见开始修改吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fine tune railmap canvas of shmetro 2020

2 participants